package cn.tedu.order.management.controller;


import cn.tedu.common.web.JsonResult;
import cn.tedu.order.management.pojo.param.OrderRefundParam;
import cn.tedu.order.management.service.RefundService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/refund/")
public class RefundController {

    @Autowired
    private RefundService refundService;

    @PostMapping("{orderId}/refund")
    public JsonResult addNew(@PathVariable Long orderId, OrderRefundParam orderRefundParam){
        refundService.addNew(orderId,orderRefundParam);
        return JsonResult.ok();
    }

    @ApiOperation("获取退款列表")
    @GetMapping("list")
    public JsonResult list(){
        return JsonResult.ok(refundService.list());
    }

    @ApiOperation("同意退款")
    @PostMapping("refundY")
    public JsonResult refundY(Long orderId){
        refundService.refundY(orderId);
        return JsonResult.ok();
    }

    @ApiOperation("拒绝退款")
    @PostMapping("refundN")
    public JsonResult refundN(Long orderId){
        System.out.println(orderId);
        refundService.refundN(orderId);
        return JsonResult.ok();
    }

}
